﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace QunYing.Web.market
{
  
    public partial class changepwd : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Repeater rp = ((Repeater)Master.FindControl("NavRepeater"));
                rp.DataSource = NavData();
                rp.DataBind();
            }
        }
        /// <summary>
        /// 快捷导航数据
        /// </summary>
        private DataTable NavData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("url");
            dt.Rows.Add("修改密码", "");
            return dt;
        }
        private string strUserName = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userInfo"] == null)
            {
                MessageBox.ResponseScript(this, "window.parent.document.location.href='../Login.aspx'");
            }
            else
            {
                strUserName = ((ArrayList)Session["userInfo"])[0].ToString();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BLL.UserLoginInfo user = new BLL.UserLoginInfo();
            ArrayList loginUser = user.Login(strUserName, txtOldPwd.Text.Trim());
            if (loginUser.Count > 0)
            {
                bool b = user.UpdatePwd(strUserName, txtNewPwd1.Text.Trim());
                if (b)
                {
                    MessageBox.ResponseScript(this, "alert('修改成功');window.parent.ymPrompt.close();");
                }
                else
                {
                    MessageBox.Show(this, "修改失败!");
                }

            }
            else
            {
                MessageBox.Show(this, "旧密码不正确!");
                txtOldPwd.Focus();
            }
        }
    }
}
